package core4.config;

import javax.servlet.Filter;
import javax.servlet.ServletRegistration.Dynamic;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class MyWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer  {

	/*
	 * @Override protected WebApplicationContext createServletApplicationContext() {
	 * System.out.println("createServletApplicationContext");
	 * XmlWebApplicationContext cxt = new XmlWebApplicationContext();
	 * cxt.setConfigLocation("classpath:springmvc.xml"); return cxt; }
	 */

	@Override
	protected String[] getServletMappings() {
		return new String[] { "/" };
	}

	/*
	 * @Override protected WebApplicationContext createRootApplicationContext() {
	 * 
	 * System.out.println("WebApplicationContext"); XmlWebApplicationContext cxt =
	 * new XmlWebApplicationContext();
	 * cxt.setConfigLocation("classpath:applicationContext.xml"); return cxt; }
	 */

	@Override
	protected Filter[] getServletFilters() {
		
		return new Filter[] { new HiddenHttpMethodFilter(), new CharacterEncodingFilter("UTF-8") };
	}

	@Override
	protected void customizeRegistration(Dynamic registration) {
		//registration.setInitParameter("enableLoggingRequestDetails", "true");
	}

	@Override
	protected Class<?>[] getRootConfigClasses() {	
		System.out.println("111111111111111111111111111111111111");
		 return new Class[] {WebSecurityConfig.class,};
		 //return new Class[] {WebSecurityConfig.class,RootApplicationConfig.class};
	}

	@Override
	protected Class<?>[] getServletConfigClasses() {
		System.out.println("222222222222222");
		
		 return new Class[] { SpringMvcConfig.class,};
	}
	

	
	
}
